test(index): make flaky IVF_RQ recall test deterministic#7679
Open
wombatu-kun wants to merge 1 commit into
Open
test(index): make flaky IVF_RQ recall test deterministic#7679wombatu-kun wants to merge 1 commit into
wombatu-kun wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
test_build_ivf_rq(rust/lance/src/index/vector/ivf/v2.rs) is flaky: it builds an IVF_RQ index over seeded random vectors and assertsrecall >= 0.5, but recall sits right on the bar and occasionally dips below. It surfaced in CI on #7371 asrecall: 0.49for thecase_2::rotation_type_1_RQRotationType__Fastpermutation (nlist=1, Cosine, Fast rotation) - see the failedlinux-buildjob: https://github.com/lance-format/lance/actions/runs/28875488220/job/85649319644. It is a pre-existing flake, not caused by any recent change to the search path.Root cause
The test data is already deterministic (
generate_random_array_with_rangeseedsStdRng::from_seed([13; 32])), but the index build is not. RaBitQ draws a random rotation at build time from an unseeded entropy RNG (random_fast_rotation_signs/random_orthogonal), and fornlist=4the IVF k-means init is unseeded as well. One rotation is drawn per build and shared by every query, so recall varies run to run around the 0.5 bar. With 1-bit RaBitQ over uniform-random 32-dim data the mean recall sits at ~0.5, so the assertion is inherently borderline (the test already carried a "RQ doesn't perform well for random data" note and a commented-out#[ignore]).Fix
Keep the strict
>= 0.5assertions and remove the flakiness by making the build deterministic through existing build-param seams, with no production change. The rotation is pinned via the existingRQBuildParams.rotationfield (the same seam distributed builds use to share a rotation): the test constructs a fixedRabitQuantizationMetadatawith fixed sign bits for the Fast rotation and a deterministic Haar-like orthogonal matrix (seeded Gaussian + Gram-Schmidt) for the Matrix rotation. The IVF centroids are pinned viaIvfBuildParams::try_with_centroids, which bypasses k-means and removes thenlist=4variance.The change is confined to
#[cfg(test)] mod tests. A no-op guard (determinize_rq_paramsreturns params unchanged unless the last stage is RQ) leaves the SQ/PQ/flat/HNSW tests that share the same helpers unaffected.Verification
All 12
test_build_ivf_rqpermutations pass, including the previously-failingcase_2::rotation_type_1_RQRotationType__Fast. Ran the matrix three times back-to-back with identical results.test_build_ivf_sqandtest_build_ivf_pqstill pass (shared-helper no-op path).cargo fmt --allandcargo clippy -p lance --tests -- -D warningsare clean.